const web = require("../../module/web"), loger = require("../../module/loger");

module.exports.run = (yzm)=>{
	web.run((w)=>{
		//判断是否登录
		let uf = w.window.document.getElementById("userinfo");
		if(uf){
			let al = uf.getElementsByTagName("a");
			for(let i=0;i<al.length;i++){
				if(al[i].innerHTML == '退出'){ //账号已经登录了
					global.sdObj.end = 0;
					return true;
				}
			}				
		}
		//输入验证码登录
		let inp = w.window.document.getElementsByName("phrase");
		if(inp && inp[0] && inp[0].clientWidth > 0) inp[0].value = yzm;
		inp = w.window.document.getElementsByClassName("quc-submit quc-button quc-button-sign-in");
		if(inp && inp[0]) inp[0].click();
	}, (w)=>{
		loger.info("lgYzm loaded");
		//判断是否登录
		let uf = w.window.document.getElementById("userinfo");
		if(uf){
			let al = uf.getElementsByTagName("a");
			for(let i=0;i<al.length;i++){
				if(al[i].innerHTML == '退出'){ //账号已经登录了
					global.sdObj.end = 0;
					return true;
				}
			}				
		}
	})
}